<?php
@include('include/common.inc.php');
$sel = "select * from $TBL_CONTACT where id =1";
$res = mysql_query($sel);
$row = mysql_fetch_array($res);
$img = $row[img];
if($_POST['add']==1)
{		
	$name = work_str($_POST["name"], 1);			
	$sex = work_str($_POST["sex"], 1);	
	$email = work_str($_POST["email"], 1);	
	$addr = work_str($_POST["addr"], 1);
	$city = work_str($_POST["city"], 1);

	$query1 = "SELECT * FROM $TBL_HOU_CATE WHERE cate_id=$city";
	$result1 = mysql_query($query1) or die(mysql_error());
	$row1 = mysql_fetch_array($result1);
	$zh_cate_title1 = $row1['zh_cate_title'];
	$parent_id = $row1['parent_id'];
	$query2 = "SELECT * FROM $TBL_HOU_CATE WHERE cate_id=$parent_id";
	$result2 = mysql_query($query2) or die(mysql_error());
	$row2 = mysql_fetch_array($result2);
	$zh_cate_title2 = $row2['zh_cate_title'];
	$cate_name = $zh_cate_title2.$zh_cate_title1;

	$city = $cate_name;

	$area = work_str($_POST["area"], 1);
	$typex = work_str($_POST["type"], 1);
	$price = work_str($_POST["price"], 1);
	$linkman = work_str($_POST["linkman"], 1);
	$demand = work_str($_POST["demand"], 1);
	$tel = work_str($_POST["tel"], 1);			
	$time =date('Y-m-d H:i:s');		
	
	$insert = "insert into $TBL_CONTACT (id,name,sex,email,addr,city,area,type,price,demand,tel,datetime)
	values (null,'$name','$sex','$email','$addr','$city','$area','$typex','$price','$demand','$tel','$time')";

	if(mysql_query($insert))
	{
		MyNotice("聯系我們發布成功", 2, "index.php");
	}else{			
		MyNotice("聯系我們發布失敗", 1, "login.php");
	}
	
}
$sel4 = "select * from $TBL_HOU_CATE where parent_id=0 order by cate_order asc";   //区域导航
$res4 =$db->query($sel4);
while($rows = $db->fetch_array($res4))
{
	$row4[]=$rows;		
}
$smarty->assign("row4",$row4);
@include('number.php');//验证码
@include('right.php');
@include('xuanxiang.php');
$smarty->assign("img",$img);
$smarty->display('contact.html');
?>